<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/TR/REC-html40" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml"><head>



<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 10">
<meta name="Originator" content="Microsoft Word 10">
<link rel="File-List" href="http://online-judge.uva.es/p/v102/p6_files/filelist.xml">
<link rel="Edit-Time-Data" href="http://online-judge.uva.es/p/v102/p6_files/editdata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>Problem G - World Finals Warmup Occidental Contest</title>
<o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype>
<o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PlaceName"></o:smarttagtype>
<o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PlaceType"></o:smarttagtype>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>Shahriar Manzoor</o:Author>
  <o:LastAuthor>Shahriar Manzoor</o:LastAuthor>
  <o:Revision>66</o:Revision>
  <o:TotalTime>198</o:TotalTime>
  <o:LastPrinted>1999-05-07T21:27:00Z</o:LastPrinted>
  <o:Created>2000-12-04T12:45:00Z</o:Created>
  <o:LastSaved>2002-03-11T06:57:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>147</o:Words>
  <o:Characters>843</o:Characters>
  <o:Company>CSE, BUET</o:Company>
  <o:Lines>7</o:Lines>
  <o:Paragraphs>1</o:Paragraphs>
  <o:CharactersWithSpaces>989</o:CharactersWithSpaces>
  <o:Version>10.2625</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:GrammarState>Clean</w:GrammarState>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>0</w:DisplayVerticalDrawingGridEvery>
  <w:UseMarginsForDrawingGridOrigin/>
  <w:Compatibility>
   <w:FootnoteLayoutLikeWW8/>
   <w:ShapeLayoutLikeWW8/>
   <w:AlignTablesRowByRow/>
   <w:ForgetLastTabAlignment/>
   <w:LayoutRawTableWidth/>
   <w:LayoutTableRowsApart/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if !mso]><object
 classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
<style>
st1\:*{behavior:url(#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Courier;
	panose-1:2 7 4 9 2 2 5 2 4 4;
	mso-font-charset:0;
	mso-generic-font-family:modern;
	mso-font-format:other;
	mso-font-pitch:fixed;
	mso-font-signature:3 0 0 0 1 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	color:black;}
h1
	{mso-style-next:Normal;
	margin:0in;
	margin-bottom:.0001pt;
	text-align:justify;
	mso-pagination:widow-orphan;
	page-break-after:avoid;
	mso-outline-level:1;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	color:black;
	mso-font-kerning:0pt;
	font-weight:normal;
	font-style:italic;}
p.MsoTitle, li.MsoTitle, div.MsoTitle
	{margin:0in;
	margin-bottom:.0001pt;
	text-align:center;
	mso-pagination:widow-orphan;
	font-size:18.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	color:black;
	font-weight:bold;
	mso-bidi-font-weight:normal;}
p.MsoBodyText, li.MsoBodyText, div.MsoBodyText
	{margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
em
	{mso-bidi-font-style:normal;}
p
	{mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
pre
	{margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
	font-size:10.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:"Times New Roman";}
p.Preformatted, li.Preformatted, div.Preformatted
	{mso-style-name:Preformatted;
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:none;
	tab-stops:0in 47.95pt 95.9pt 143.85pt 191.8pt 239.75pt 287.7pt 335.65pt 383.6pt 431.55pt 479.5pt;
	layout-grid-mode:char;
	font-size:10.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";}
</style>
<![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="3074"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head><body style="" lang="EN-US">

<div class="Section1">

<p class="MsoTitle">Problem G</p>

<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><span style="font-size: 24pt;">Common Permutation</span><o:p></o:p></b></p>

<p class="MsoNormal" style="text-align: center;" align="center"><b><span style="">Input: </span></b><span style="">standard input<o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: center;" align="center"><b><span style="">Output: </span></b><span style="">standard output<o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: center;" align="center"><b><span style="">Time Limit:</span></b><span style=""> 4 seconds<o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><span style="">Memory Limit: </span></b><span style="">32 MB</span><o:p></o:p></p>

<p class="MsoNormal"><b><span style="color: windowtext;"><o:p>&nbsp;</o:p></span></b></p>

<p class="MsoNormal"><span style="color: windowtext;">Given
two strings of lowercase letters, <b style=""><i>a</i></b>
and <b style=""><i>b</i></b>, print the longest
string <b style=""><i>x</i></b> of lowercase letters
such that there is a permutation of <b style=""><i>x</i></b>
that is a subsequence of <b style=""><i>a</i></b>
and there is a permutation of <b style=""><i>x</i></b>
that is a subsequence of <b style=""><i>b</i></b>. <o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 18pt;"><o:p>&nbsp;</o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 18pt;">Input</span><o:p></o:p></b></p>

<p class="MsoNormal" style="text-align: justify;"><span style="color: windowtext;">Input file contains several lines of input.
Consecutive two lines make a set of input. That means in the input file line <b style="">1</b> and <b style="">2</b> is a set of input, line <b style="">3</b>
and <b style="">4</b> is a set of input and so on.
The first line of a pair contains <b style=""><i>a</i></b>
and the second contains <b style=""><i>b</i></b>.
Each string is on a separate line and consists of at most <b style="">1000</b> lowercase letters.</span></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 18pt;"><o:p>&nbsp;</o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 18pt;">Output<o:p></o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><span style="color: windowtext;">For each set of input, output a line containing <b style=""><i>x</i></b>. If several <b style=""><i>x</i></b> satisfy the criteria above,
choose the first one in alphabetical order. <o:p></o:p></span></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 14pt;"><o:p>&nbsp;</o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 18pt;">Sample Input:</span><o:p></o:p></b></p>

<pre>pretty</pre><pre>women</pre><pre>walking</pre><pre>down</pre><pre>the</pre><pre>street</pre><pre><o:p>&nbsp;</o:p></pre>

<p class="MsoNormal" style="text-align: justify;"><b><span style="font-size: 18pt;">Sample Output:</span><o:p></o:p></b></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: windowtext;">e<o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: windowtext;">nw<o:p></o:p></span></p>

<p class="MsoNormal" style=""><span style="color: windowtext;">et</span><span style="font-family: Courier; color: windowtext;"><o:p></o:p></span></p>

<div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: Courier; color: windowtext;">

<hr size="2" width="100%" align="center">

</span></div>

<p class="MsoNormal" style=""><b>(World
Finals Warm-up Contest, Problem Source: </b><st1:place><st1:placetype><b>University</b></st1:placetype><b>
 of </b><st1:placename><b>Alberta</b></st1:placename></st1:place><b> Local
Contest)</b><span style="color: windowtext;"><o:p></o:p></span></p>

</div>

</body></html>